home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_13_1986_Transactor_Publishing.d64 / pythago triplets (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  439b  |  16 lines

  1. 100 rem pythagorean triplets by rai -86
  2. 110 print"[147]   u   v     u^2-v^2     2uv   u^2+v^2"
  3. 120 print"  ====================================="
  4. 130 n=10: rem number of solutions
  5. 140 dim a(n-1),b(n-1),c(n-1)
  6. 150 quit=n: j=0: u=2: v=1
  7. 160 u2=u*u: v2=v*v
  8. 170 a(j)=u2-v2: b(j)=2*u*v: c(j)=u2+v2
  9. 180 print tab(2);u;tab(6);v;tab(15);a(j);tab(25);b(j);tab(34);c(j)
  10. 190 j=j+1: if j=quit then end
  11. 200 if u-v = 1 then goto 220
  12. 210 v=v+2: goto 160
  13. 220 u=u+1: v=1
  14. 230 if (u and 1)=1 then v=2
  15. 240 goto 160
  16.